//
//  LCCircleAnimationView.m
//  HQBProject
//
//  Created by taolei-mac on 2017/4/19.
//  Copyright © 2017年 com.zhejiangchain.ios. All rights reserved.
//

#import "LCCircleAnimationView.h"
#import "LCCircleProgressView.h"
#import "LCPointView.h"

@interface LCCircleAnimationView ()
@property (nonatomic, weak) LCCircleProgressView *circleProgressView;
@property (nonatomic, weak) LCPointView *pointView;
@end

@implementation LCCircleAnimationView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if(self){
        
        [self initProgressCircleView];
        
        [self initPointView];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if(self){
        
        [self initProgressCircleView];
        
        [self initPointView];
    }
    return self;
}

/**
  *  初始化进度环
 */
- (void)initProgressCircleView
{
    LCCircleProgressView *circleProgressView = [[LCCircleProgressView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height)];
    [self addSubview:circleProgressView];
    self.circleProgressView = circleProgressView;
}

/**
 *   添加圆点
 */
- (void)initPointView
{
    LCPointView *pointView = [[LCPointView alloc] initWithFrame:CGRectMake(0, 0, self.width - 30, self.height - 30)];
    pointView.backgroundColor = [UIColor clearColor];
    pointView.center = CGPointMake(self.width * 0.5, self.height * 0.5);
    [self addSubview:pointView];
    self.pointView = pointView;
}

- (void)setPercent:(NSInteger)percent
{
    [self.circleProgressView makeProgressCircle:percent withAnimationTime:1.5];
    
    [self.pointView updatePointView:percent withAnimationTime:1.5];
    _percent = percent;
}

@end
